package main

import "fmt"

func l189Rotate(nums []int, k int) {
	fmt.Println("--- start... ---")
	lon := len(nums)
	for k > 0 {
		sw := nums[lon-1]
		for i := lon - 1; i >= 1; i-- {
			nums[i] = nums[i-1]
		}
		nums[0] = sw
		k--
	}
}

func betterl189Rotate(nums []int, k int) {
	fmt.Println("--- start... ---")
	lon := len(nums)
	k = k % lon
	pre := nums[lon-k:]
	last := nums[0 : lon-k]
	newnums := append(pre, last...)
	for i, _ := range newnums {
		nums[i] = newnums[i]
	}
}
